<template>
  <div class="form-rate form-components" :style="newStyle">
    <div v-if="$attrs.readonly || $attrs.onlyShow" class="form-readonly"></div>
    <el-rate
      v-model="formValue"
      v-bind="$attrs"
      @change="onChange"
      :colors="[$attrs.color, $attrs.color, $attrs.color]"
      :void-color="$attrs.voidColor"
    />
  </div>
</template>

<script>
import { comMixin } from "../../../utils/comMixins";
export default {
  mixins: [comMixin],
  name: "form-rate",
  model: {
    prop: "modelValue", // 绑定的值，通过父组件传递
    event: "update",
  },
  props: {
    modelValue: {
      type: [String, Number],
      default: "",
    },
  },

  computed: {
    formValue: {
      get() {
        return this.modelValue;
      },
      set(val) {
        this.$emit("update:modelValue", val);
      },
    },
  },
};
</script>

<style lang="scss">
.form-rate {
  min-height: 36px;
  line-height: 36px;
  display: flex;
  align-items: center;
}
</style>
